home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _C5081EBF4DC6489E9353C29700B5FBAF < prev    next >
Encoding:
Text File  |  2004-01-06  |  3.7 KB  |  142 lines

  1. Fog = {
  2.     type = "FogController",
  3.     Properties = {    
  4.         StartDist = 30,
  5.         EndDist = 100,
  6.         clrColor={0.5,0.6,0.5},
  7.         xSkyStart = 250,        --    when fogEnd (EndDist) less than this - sky starts to fade 
  8.         xSkyEnd = 150,            --  when fogEnd (EndDist) less than this - sky is faded complitly 
  9.         },
  10.     Editor={
  11.         Model="Objects/Editor/T.cgf",
  12.     },
  13.     
  14.     outsideStart = 0,
  15.     outsideEnd = 0,
  16.     outsideColor = {0.0,0.0,0.0},
  17.     
  18.     curStart = 0,
  19.     curEnd = 0,
  20.     curColor = {0.0,0.0,0.0},
  21.     
  22.     doStart = 0,
  23.     doEnd = 0,
  24.     doColor = 0,
  25.     
  26.     occupied = 0,
  27. }
  28.  
  29.  
  30. function Fog:OnInit()
  31.     self:OnReset();
  32.     
  33.     self.outsideStart = System:GetFogStart();
  34.     self.outsideEnd = System:GetFogEnd();
  35.     self.outsideColor = System:GetFogColor();
  36. end
  37.  
  38. function Fog:OnPropertyChange()
  39.     self:OnReset();
  40. end
  41.  
  42. function Fog:OnReset()
  43.  
  44.     if(self.occupied == 1 ) then
  45.         self:OnLeaveArea( );
  46.     end    
  47.  
  48.     if(self.Properties.StartDist ~= 0) then
  49.         self.doStart = 1;
  50.     end
  51.     if(self.Properties.EndDist ~= 0) then
  52.         self.doEnd = 1;
  53.     end
  54.     if(self.Properties.clrColor[1] ~= 0 or self.Properties.clrColor[2] ~= 0 or self.Properties.clrColor[3] ~= 0 ) then
  55.         self.doColor = 1;
  56.     end
  57.     
  58.     self.occupied = 0;
  59. end
  60. -----------------------------------------------------------------------------
  61. --    fade: 0-out 1-in
  62. function Fog:OnProceedFadeArea( player,areaId,fadeCoeff )
  63.  
  64. --System.LogToConsole("--> Fade Proceed "..areaId.." FadeIS "..fadeCoeff);
  65. --    System.SetViewDistance(1200);
  66.  
  67. --    if(player ~= _localplayer) then
  68. --        return
  69. --    end    
  70.  
  71. --System.LogToConsole("--> Fade Proceed MY");
  72. --System.LogToConsole("-->FadeIS "..fadeCoeff.." "..self.Properties.EndDist.." "..Lerp(self.outsideEnd, self.Properties.EndDist, fadeCoeff));
  73.  
  74.     fadeCoeff = sqrt( fadeCoeff );
  75.     fadeCoeff = sqrt( fadeCoeff );
  76.  
  77.     if(self.doStart==1) then
  78.         self.curStart = Lerp(self.outsideStart, self.Properties.StartDist, fadeCoeff);
  79.         System:SetFogStart(self.curStart);
  80.     end    
  81.  
  82.     if(self.doEnd==1) then
  83.         self.curEnd = Lerp(self.outsideEnd, self.Properties.EndDist, fadeCoeff);
  84.         System:SetFogEnd(self.curEnd);
  85.     end    
  86.  
  87.  
  88. --System.LogToConsole("--> COlor "..self.Properties.clrColor[1].." "..self.Properties.clrColor[2].." "..self.Properties.clrColor[3].." -- "..self.doColor);
  89. --System.FogColorSet(self.Properties.clrColor);
  90.     if(self.doColor==1) then
  91.         self.curColor = LerpColors(self.outsideColor, self.Properties.clrColor, fadeCoeff);
  92.         System:SetFogColor(self.curColor);
  93.     end    
  94. end
  95.  
  96. -----------------------------------------------------------------------------
  97. function Fog:OnEnterArea( player,areaId )
  98.  
  99. --System.Log("--> Entering Fog Area "..areaId.." "..self.Properties.clrColor[1].." "..self.Properties.clrColor[2].." "..self.Properties.clrColor[3]);
  100.  
  101. --    if(player ~= _localplayer) then
  102. --        return;
  103. --    end    
  104. --System.LogToConsole("--> Entering Fog Area MY ");
  105.  
  106.     if(self.occupied == 1) then return end
  107.  
  108.     self.outsideStart = System:GetFogStart();
  109.     self.outsideEnd = System:GetFogEnd();
  110.     self.outsideColor = System:GetFogColor();
  111.  
  112.     System:SetSkyFade( self.Properties.xSkyStart, self.Properties.xSkyEnd );
  113.  
  114.     self.occupied = 1;
  115. end
  116.  
  117. -----------------------------------------------------------------------------
  118. function Fog:OnLeaveArea( player,areaId )
  119.  
  120. --System.Log("--> Leaving Fog Area "..areaId);
  121.  
  122. --    if(player ~= _localplayer) then
  123. --        return;
  124. --    end    
  125.     
  126. --System.LogToConsole("--> Leaving Fog Area MY ");    
  127.  
  128.     if(self.doStart==1) then
  129.         System:SetFogStart(self.outsideStart);
  130.     end    
  131.     if(self.doEnd==1) then    
  132.         System:SetFogEnd(self.outsideEnd);
  133.     end    
  134.     if(self.doColor==1) then    
  135.         System:SetFogColor(self.outsideColor);
  136.     end    
  137.     
  138.     self.occupied = 0;
  139. end
  140. -----------------------------------------------------------------------------
  141. function Fog:OnShutDown()
  142. end